package com.jianbing.shasha.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.jianbing.common.utils.SecurityUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jianbing.common.annotation.Log;
import com.jianbing.common.core.controller.BaseController;
import com.jianbing.common.core.domain.AjaxResult;
import com.jianbing.common.enums.BusinessType;
import com.jianbing.shasha.domain.ShashaPart5Ques;
import com.jianbing.shasha.service.IShashaPart5QuesService;
import com.jianbing.common.utils.poi.ExcelUtil;
import com.jianbing.common.core.page.TableDataInfo;

/**
 * 【请填写功能名称】Controller
 * 
 * @author ruoyi
 * @date 2024-06-16
 */
@RestController
@RequestMapping("/shasha/ques")
public class ShashaPart5QuesController extends BaseController
{
    @Autowired
    private IShashaPart5QuesService shashaPart5QuesService;

    /**
     * 查询【请填写功能名称】列表
     */
    //  @PreAuthorize("@ss.hasPermi('shasha:ques:list')")
    @GetMapping("/list")
    public TableDataInfo list(ShashaPart5Ques shashaPart5Ques)
    {
        startPage();
        List<ShashaPart5Ques> list = shashaPart5QuesService.selectShashaPart5QuesList(shashaPart5Ques);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    //  @PreAuthorize("@ss.hasPermi('shasha:ques:export')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ShashaPart5Ques shashaPart5Ques)
    {
        List<ShashaPart5Ques> list = shashaPart5QuesService.selectShashaPart5QuesList(shashaPart5Ques);
        ExcelUtil<ShashaPart5Ques> util = new ExcelUtil<ShashaPart5Ques>(ShashaPart5Ques.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    //  @PreAuthorize("@ss.hasPermi('shasha:ques:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(shashaPart5QuesService.selectShashaPart5QuesById(id));
    }

    /**
     * 新增【请填写功能名称】
     */
    // @PreAuthorize("@ss.hasPermi('shasha:ques:add')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ShashaPart5Ques shashaPart5Ques)
    {
        return toAjax(shashaPart5QuesService.insertShashaPart5Ques(shashaPart5Ques));
    }

    /**
     * 修改【请填写功能名称】
     */
    // @PreAuthorize("@ss.hasPermi('shasha:ques:edit')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ShashaPart5Ques shashaPart5Ques)
    {
        return toAjax(shashaPart5QuesService.updateShashaPart5Ques(shashaPart5Ques));
    }

    /**
     * 删除【请填写功能名称】
     */
    // @PreAuthorize("@ss.hasPermi('shasha:ques:remove')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(shashaPart5QuesService.deleteShashaPart5QuesByIds(ids));
    }


    /**
     * 获取第五大关题目详细信息
     */
    // @PreAuthorize("@ss.hasPermi('shasha:ques:query')")
    @GetMapping()
    public AjaxResult getQues()
    {
        Long userId = SecurityUtils.getUserId();
        return success(shashaPart5QuesService.getQuesNotPlayByUserId(userId));
    }

}
